﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LinSM
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
        }

        private void tsmiB_Click(object sender, EventArgs e)
        {
            Form[] childform = this.MdiChildren;
            bool check = true;

            foreach (Form f in childform)
            {
                if (f is Characters)
                {
                    check = false;
                    f.Activate();
                }
            }
            if (check)
            {
                Characters f1 = new Characters();
                //f1.Tag = this;
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void tsmiC_Click(object sender, EventArgs e)
        {
            Form[] childform = this.MdiChildren;
            bool check = true;

            foreach (Form f in childform)
            {
                if (f is GiveClan)
                {
                    check = false;
                    f.Activate();
                }
            }
            if (check)
            {
                GiveClan f1 = new GiveClan();
                //f1.Tag = this;
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }

        private void tsmiD_Click(object sender, EventArgs e)
        {
            Form[] childform = this.MdiChildren;
            bool check = true;

            foreach (Form f in childform)
            {
                if (f is AllItem)
                {
                    check = false;
                    f.Activate();
                }
            }
            if (check)
            {
                AllItem f1 = new AllItem();
                //f1.Tag = this;
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void tsmiE_Click(object sender, EventArgs e)
        {
            Form[] childform = this.MdiChildren;
            bool check = true;

            foreach (Form f in childform)
            {
                if (f is DropList)
                {
                    check = false;
                    f.Activate();
                }
            }
            if (check)
            {
                DropList f1 = new DropList();
                //f1.Tag = this;
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void tsmiF_Click(object sender, EventArgs e)
        {
            Form[] childform = this.MdiChildren;
            bool check = true;

            foreach (Form f in childform)
            {
                if (f is NpcList)
                {
                    check = false;
                    f.Activate();
                }
            }
            if (check)
            {
                NpcList f1 = new NpcList();
                //f1.Tag = this;
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void tsmiG_Click(object sender, EventArgs e)
        {
            Form[] childform = this.MdiChildren;
            bool check = true;

            foreach (Form f in childform)
            {
                if (f is Shop)
                {
                    check = false;
                    f.Activate();
                }
            }
            if (check)
            {
                Shop f1 = new Shop();
                //f1.Tag = this;
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Activate();
            Visible = true; //显示窗体
            WindowState = FormWindowState.Normal;  //恢复窗体默认大小
            
        }

        private void Main_SizeChanged(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.Visible = false;   //隐藏窗体
                notifyIcon1.Visible = true; //任务栏显示图标
                notifyIcon1.ShowBalloonTip(3500, "提示", "双击恢复LinSM", ToolTipIcon.Info); //出显汽泡提示，可以不用
                this.ShowInTaskbar = false; //从状态栏中隐藏
            }
        }

        private void Main_Load(object sender, EventArgs e)
        {
            System.Diagnostics.Process.GetCurrentProcess().MaxWorkingSet = (IntPtr)750000;
        }

        private void toolStripStatusLabel2_Click(object sender, EventArgs e)
        {
            //LinSMT lsm = new LinSMT();
            //lsm.ShowDialog();
        }

        private void tsmiI_Click(object sender, EventArgs e)
        {
            Form[] childform = this.MdiChildren;
            bool check = true;

            foreach (Form f in childform)
            {
                if (f is Event)
                {
                    check = false;
                    f.Activate();
                }
            }
            if (check)
            {
                Event f1 = new Event();
                //f1.Tag = this;
                f1.MdiParent = this;
                f1.Show();
            }
        }


    }
}
